GtkWidget *window;
GtkWidget *fc_button;
GtkWidget *fc_dialog;
+ int iterations;
+ int i;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show_all (window);
wait_for_idle ();
+ /* If there is a dialog to be opened, we actually test going through it a
+ * couple of times. This ensures that any state that the button frobs for
+ * each appearance of the dialog will make sense.
+ */
if (setup->open_dialog)
+ iterations = 2;
+ else
+ iterations = 1;
+
+ for (i = 0; i < iterations; i++)
{
- GList *children;
+ if (setup->open_dialog)
+ {
+ GList *children;
- /* Hack our way into the file chooser button; get its GtkButton child and click it */
- children = gtk_container_get_children (GTK_CONTAINER (fc_button));
- g_assert (children && GTK_IS_BUTTON (children->data));
- gtk_button_clicked (GTK_BUTTON (children->data));
- g_list_free (children);
+ /* Hack our way into the file chooser button; get its GtkButton child and click it */
+ children = gtk_container_get_children (GTK_CONTAINER (fc_button));
+ g_assert (children && GTK_IS_BUTTON (children->data));
+ gtk_button_clicked (GTK_BUTTON (children->data));
+ g_list_free (children);
- wait_for_idle ();
+ wait_for_idle ();
- /* Give me the internal dialog, damnit */
- fc_dialog = g_object_get_qdata (G_OBJECT (fc_button), delegate_get_quark ());
- g_assert (GTK_IS_FILE_CHOOSER (fc_dialog));
- g_assert (GTK_IS_DIALOG (fc_dialog));
- }
+ /* Give me the internal dialog, damnit */
+ fc_dialog = g_object_get_qdata (G_OBJECT (fc_button), delegate_get_quark ());
+ g_assert (GTK_IS_FILE_CHOOSER (fc_dialog));
+ g_assert (GTK_IS_DIALOG (fc_dialog));
+ }
- /* Okay, now frob the button and its optional dialog */
+ /* Okay, now frob the button and its optional dialog */
- if (setup->tweak_current_folder)
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc_button), setup->tweak_current_folder);
+ if (setup->tweak_current_folder)
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (fc_button), setup->tweak_current_folder);
- if (setup->tweak_filename)
- gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (fc_button), setup->tweak_filename);
+ if (setup->tweak_filename)
+ gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (fc_button), setup->tweak_filename);
- sleep_in_main_loop ();
+ sleep_in_main_loop ();
- if (setup->open_dialog)
- {
- gtk_dialog_response (GTK_DIALOG (fc_dialog), setup->dialog_response);
- wait_for_idle ();
- }
+ if (setup->open_dialog)
+ {
+ gtk_dialog_response (GTK_DIALOG (fc_dialog), setup->dialog_response);
+ wait_for_idle ();
+ }
- if (setup->final_current_folder)
- {
- char *folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (fc_button));
+ if (setup->final_current_folder)
+ {
+ char *folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (fc_button));
- g_assert_cmpstr (folder, ==, setup->final_current_folder);
- g_free (folder);
- }
+ g_assert_cmpstr (folder, ==, setup->final_current_folder);
+ g_free (folder);
+ }
- if (setup->final_filename)
- {
- char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fc_button));
+ if (setup->final_filename)
+ {
+ char *filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fc_button));
- g_assert_cmpstr (filename, ==, setup->final_filename);
- g_free (filename);
+ g_assert_cmpstr (filename, ==, setup->final_filename);
+ g_free (filename);
+ }
}
gtk_widget_destroy (window);